package com.peking.donations.task;

import com.peking.donations.plugins.pay.wx.service.AuthorizeService;
import com.peking.donations.plugins.pay.wx.utils.WxpayException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Created by wyz on 16/4/28.
 */
@Component
public class WXTokenTask {

    private Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    AuthorizeService authorizeService;


    //@Scheduled(cron = "0 0 0/2 * * ?")
    public  void accessToken() {
        try {
            authorizeService.refreshAccessToken();
            authorizeService.refreshJSTicket();
        }catch (WxpayException e){
            e.printStackTrace();
            logger.error(" 定时获取access_token 失败!返回值[" + e.getMessage() + "]",e);
        }
    }
}
